<template>
    <a-config-provider :locale="locale">
        <a-spin :spinning="spinning" tip="加载中...">
            <router-view></router-view>
        </a-spin>
  </a-config-provider>
</template>
<script setup lang="ts">
import { onUnmounted, ref } from "vue";
import settingStore from "@/store/setting";
import zhCN from 'ant-design-vue/es/locale/zh_CN';

let locale = ref(zhCN)
//加载
let spinning = ref<boolean>(false);
const settingInfo = settingStore();
//清零
settingInfo.resetLoading();
//订阅监听
const unsubscribe = settingInfo.$subscribe(
    (_actions: any, state: { loadingCount: number }) => {
        if (state.loadingCount <= 0) {
            spinning.value = false;
        } else {
            spinning.value = true;
        }
    }
);
// 取消订阅
onUnmounted(() => {
    unsubscribe();
});

</script>
